package com.zcx.qshop.view;

import android.content.Context;
import android.graphics.Color;
import android.net.Uri;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;

import com.facebook.drawee.view.SimpleDraweeView;
import com.zcx.qshop.QSApplication;
import com.zcx.qshop.R;
import com.zcx.qshop.conn.JsonGoodinfoAsyGet;
import com.zcx.qshop.flow.CircleFlowIndicator;
import com.zcx.qshop.flow.ViewFlowAdvert;

/**
 * Created by Administrator on 2015/8/9 0009.
 */
public class CommodityDetailBannerView extends ViewFlowAdvert<JsonGoodinfoAsyGet.Info.Picurl> {

    private LayoutInflater layoutInflater;

    private OnItemClickListener onItemClickListener;

    public CommodityDetailBannerView(Context context, AttributeSet attrs) {

        super(context, attrs);

        layoutInflater = LayoutInflater.from(context);

    }

    @Override
    protected View loadView(View view, final JsonGoodinfoAsyGet.Info.Picurl banner) {

        SimpleDraweeView simpleDraweeView = (SimpleDraweeView) view.findViewById(R.id.item_commodity_detail_banner_img);

        simpleDraweeView.setImageURI(Uri.parse(banner.picurl));

        view.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {

                if(onItemClickListener != null){

                    onItemClickListener.onItemClick(banner);

                }

            }

        });

        return view;

    }

    @Override
    protected View createView() {

        return layoutInflater.inflate(R.layout.item_commodity_detail_banner, null);

    }

    @Override
    protected View indicatorLayout(CircleFlowIndicator circleFlowIndicator) {

        circleFlowIndicator.setFillColor(getContext().getResources().getColor(R.color.dominant_tone_one));

        circleFlowIndicator.setStrokeColor(Color.parseColor("#c0b9ae"));

        circleFlowIndicator.setRadius(QSApplication.ScaleScreenHelper.getWidthHeight(10));

        circleFlowIndicator.setCircleSeparation(QSApplication.ScaleScreenHelper.getWidthHeight(30));

        return circleFlowIndicator;

    }

    public void setOnItemClickListener(OnItemClickListener onItemClickListener){

        this.onItemClickListener = onItemClickListener;

    }

    public interface OnItemClickListener{

        void onItemClick(JsonGoodinfoAsyGet.Info.Picurl banner);

    }

}
